use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Order {
    pub id: i32,
    pub material_id: i32,
    pub client_id: i32,
    pub contact_id: i32,
    pub quantity: i32,
    pub price: i32,
    pub amount: i32,
    pub unit: String, //单位，美元，人民币元

    pub place_order_date: chrono::NaiveDateTime,

    pub plan_delivery_date: chrono::NaiveDateTime,

    pub actual_delivery_date: Option<chrono::NaiveDateTime>,

    pub status: i8,
    pub remark: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_path: Option<String>,
    #[serde(skip)]
    pub created_at: chrono::NaiveDateTime,
    #[serde(skip)]
    pub created_by: String,
    #[serde(skip)]
    pub modified_at: chrono::NaiveDateTime,
    #[serde(skip)]
    pub modified_by: String,

    // 新增字段，用于前端显示
    #[serde(skip_serializing_if = "Option::is_none")]
    pub customer_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub customer_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub material_name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub material_code: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub contact_name: Option<String>,
}
